<?php
/**
 * @desc 合同模版表模型
 */
namespace Home\Model;
use Think\Model;
class ContractTemplateModel extends BaseModel{
    
    //短信剩余数量表
    protected $tableName = 'tp_contract_template';
    
    /**
     * 获取合同模版
     * @author cheng
     */
    public function getTemplate() {
        $result = $this->where(['f_contract_id' => 1, 'f_contract_type' => 1])->find();
        return $result;
    }
    
    /**
     * 替换合同模版中的关键字
     * @param type $content 内容
     * @param type $user_info 用户信息
     * @author cheng
     */
    public function replaceWords($content, $user_info) {
        $year = date('Y');
        $mon = date('m');
        $day = date('d');
        $result = str_replace('{name}', $user_info['f_user_name'], $content);
        $result = str_replace('{id}', $user_info['tp_users_additional'], $result);
        $result = str_replace('{province}', $user_info['f_province_name'], $result);
        $result = str_replace('{city}', $user_info['f_city_name'], $result);
        $result = str_replace('{area}', $user_info['f_area_name'], $result);
        $result = str_replace('{address}', $user_info['f_address'], $result);
        $result = str_replace('{year}', $year, $result);
        $result = str_replace('{mon}', $mon, $result);
        $result = str_replace('{day}', $day, $result);
        $result = str_replace('{nyear}', $year+1, $result);
        $result = str_replace('{nmon}', $mon, $result);
        $result = str_replace('{nday}', $day, $result);
        $result = str_replace('{mobile}', $user_info['f_user_mobile'], $result);
        return $result;
    }
    
    
}